/**
 * 存储数据的工具模块
 * 1.存储token===>localStorge
 * 2.存储登录用户的信息===>sessionStorage
 * 3.存储当前页码====>sessionStorage
 */

const TOKEN_KEY = 'token_key'
const USER_KEY = 'user_key'
const PAGE_KEY = 'page_key'

export const saveToken = token => localStorage.setItem(TOKEN_KEY, token)
export const getToken = () => localStorage.getItem(TOKEN_KEY)
export const removeToken = () => localStorage.removeItem(TOKEN_KEY)

export const saveUser = user => localStorage.setItem(USER_KEY, JSON.stringify(user))
export const getUser = () => JSON.parse(localStorage.getItem(USER_KEY))
export const removeUser = () => localStorage.removeItem(USER_KEY)

export const saveKey = page => sessionStorage.setItem(PAGE_KEY, page)
export const getKey = () => sessionStorage.getItem(PAGE_KEY)
export const removeKey = () => sessionStorage.removeItem(PAGE_KEY)